package com.example.famhealing.timeline;

import java.util.ArrayList;

import com.example.famhealing.R;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;
 
//타임라인 중 '컨디션' 부분 리스트 어댑터
public class ConditionListAdapter extends ArrayAdapter<Condition_List_Data> {
 
    private ArrayList<Condition_List_Data> items;
    
    LinearLayout memoBar;
    LinearLayout medicineBar;
    LinearLayout feelingBar;
    LinearLayout conditionBar;
 
    public ConditionListAdapter(Context context, int textViewResourceId,
            ArrayList<Condition_List_Data> items) {
        super(context, textViewResourceId, items);
        this.items = items; 
    }
 
    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        View v = convertView;
        if (v == null) {
            
            LayoutInflater vi = (LayoutInflater) getContext().getSystemService(
                    Context.LAYOUT_INFLATER_SERVICE);
            v = vi.inflate(R.layout.timeline_condition_list, null);
        }
        Condition_List_Data condition_list_data = items.get(position);
 
        if (condition_list_data != null) {
            
            TextView tv_memo = (TextView) v.findViewById(R.id.memo);
            TextView tv_medicine = (TextView) v.findViewById(R.id.medicine);
            TextView tv_feeling = (TextView) v.findViewById(R.id.feeling);
            TextView tv_condition = (TextView) v.findViewById(R.id.condition);
            
            memoBar = (LinearLayout) v.findViewById(R.id.memoBar);
            medicineBar = (LinearLayout) v.findViewById(R.id.medicineBar);
            feelingBar = (LinearLayout) v.findViewById(R.id.feelingBar);
            conditionBar = (LinearLayout) v.findViewById(R.id.conditionBar);
            
            //각 TextView에 맞는 글을 넣어줌         
            tv_memo.setText(condition_list_data.getMemo());
            tv_medicine.setText(condition_list_data.getMedicine());
            tv_feeling.setText(condition_list_data.getFeeling());
            tv_condition.setText(condition_list_data.getCondition());
            
        }
 
        return v;
    }
}
 
class Condition_List_Data {
	private String memo;
    private String medicine;
    private String feeling;
    private String condition;
    
    /*
    private String memoWriter;
    private String medicineWriter;
    private String feelingWriter;
    private String conditionWriter;
 	*/
    
    public Condition_List_Data(String memo, String medicine, String feeling, String condition) {
        this.setMemo(memo);
        this.setMedicine(medicine);
        this.setFeeling(feeling);
        this.setCondition(condition);
    }
    
    /*
    public Condition_List_Data(String memo, String medicine, String feeling, String condition
    		, String memoWriter, String medicineWriter, String feelingWriter, String conditionWriter) {
        this.setMemo(memo);
        this.setMedicine(medicine);
        this.setFeeling(feeling);
        this.setCondition(condition);
        
        this.setMemoWriter(memoWriter, medicineWriter, feelingWriter, conditionWriter);
    }
    */
    
    public String getMemo() {
    	return memo;
    }
 
    public void setMemo(String memo) {
    	this.memo = memo;
    }
    
    public String getMedicine() {
        return medicine;
    }
 
    public void setMedicine(String medicine) {
        this.medicine = medicine;
    }
 
    public String getFeeling() {
        return feeling;
    }
 
    public void setFeeling(String feeling) {
        this.feeling = feeling;
    }
    
    public String getCondition() {
        return condition;
    }
 
    public void setCondition(String condition) {
        this.condition = condition;
    }
    
    /* 해당 색으로 표시
    public void setColor(String memoWriter, String medicineWriter, String feelingWriter, String conditionWriter) {
    	if(memoWriter.equals("")) {
    		
    	}
    }
    */
    
}